<template>
  <!-- 扫描二维码后 跳转的页面 -->
  <view class="newManagerVerify">
    <view class="nexSite-item">
      <view class="stateText">点击下方“确认”按钮，您将成为</view>
      <view class="information">
        <view class="name">{{ infoList.companyName }}</view>
        <view class="address">
          <image :src="baseImgUrl + 'newadd_icon.png'" mode=""></image>
          {{ infoList.companyAddressDetail }}
        </view>
      </view>
      <view class="stateText" style="padding-top: 40rpx">的企业管理员！</view>
      <view class="btns">
        <button class="submit-btn" type="primary" icon="map" style="width: 100%" @click="submithandle">
          确认
        </button>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    findCompanyInfo,
    userInsert
  } from "@/api/myself.js";
  import {
    Toast
  } from "@/utils/util.js";

  export default {
    name: "newManagerVerify",
    data() {
      return {
        baseImgUrl: this.$baseImgUrl,
        options: {},
        infoList: {},
      };
    },
    onLoad(options) {
      this.options = options;
      this.getList();
    },
    methods: {
      submithandle() {
        userInsert({
          scene: this.options.scene
        }).then((res) => {
          if (res.code == 200) {
            Toast(res.message);
            setTimeout(() => {
              uni.reLaunch({
                url: "/pages/home/home",
              });
            }, 1000);
          } else if (code == 400) {
            Toast(res.message);
          }
        });
      },
      getList() {
        let token = uni.getStorageSync("X-MINI-TOKEN");
        if (!token) {
          Toast('请先登录登录小程序后，再扫码！')
          setTimeout(() => {
            uni.reLaunch({
              url: "/pages/beforeLogin/beforeLogin",
            });
          }, 1500);
          return
        }
        findCompanyInfo({
          scene: this.options.scene
        }).then((res) => {
          if (res.code == 200) {
            this.infoList = res.result;
          }
        });
      },
    },
  };
</script>

<style lang="scss">
  .newManagerVerify {
    padding: 20rpx;
    background: #f9f9f9;

    .nexSite-item {
      height: calc(100vh - 22px);
      background: #fff;
      text-align: center;

      .stateText {
        padding: 80rpx 0 50rpx;
        font-size: 32rpx;
        font-weight: bold;
        color: #333333;
        text-align: center;
      }

      .information {
        margin: 0 20rpx;
        padding: 35rpx 0;
        width: 100%;
        background: #f9f9f9;
        text-align: center;

        .name {
          padding-bottom: 35rpx;
          font-size: 36rpx;
          font-weight: bold;
          color: #2488f5;
        }

        .address {
          padding-bottom: 25rpx;
          font-size: 28rpx;
          font-weight: 500;
          color: #858894;

          image {
            margin-right: 10rpx;
            width: 22rpx;
            height: 28rpx;
          }
        }
      }
    }
  }
</style>